import {
  SAVE_BIOLOGICAL_CQ_DATA, SAVE_BIOLOGICAL_CQ_DATA_,
  SAVE_BIOLOGICAL_GROUPS_LIST, SAVE_BIOLOGICAL_TABLE_DATA,
  SAVE_CHART_OPTION,
  SAVE_EXPERIMENT_SETTING,
  SAVE_GENE_EXPRESSION_TABLE_LIST,
  SAVE_GENE_SETTING,
  SAVE_TABLE_DATA,
  SAVE_TARGET_CQ_DATA,
  SAVE_TECHNICAL_TABLE_DATA
} from "./constants";

const defaultState = {
  geneSetting: {
    mode: "Normalized Expression (ΔΔCq)",
    plotType: "RQ vs Sample",
    graphType: "Linear",
    orientation: "Vertical Bars",
    // mode_cn: "归一化表达分析(ΔΔCq)",
    // plotType_cn: "RQ vs 样品",
    // graphType_cn: "线性",
    // orientation_cn: "垂直",
    biologicalReplicatesGroupReference: "",
    confidenceLevel: null,
    standardDeviation: null,
    activeIndex: 1//技术or生物重复
  },
  experimentSetting: {
    targets: [],
    samples: [],
    groups: []
  },
  chartOption: {},
  geneExpressionTableList: [],
  biologicalGroupsList: [],
  targetCqData: {},
  biologicalCqData: {},
  tableData: [],
  technicalTableData: [],
  biologicalTableData: []
};

function reducer(state = defaultState, action) {
  switch (action.type) {
    case SAVE_GENE_SETTING :
      return {...state, geneSetting: action.geneSetting};
    case SAVE_EXPERIMENT_SETTING :
      return {...state, experimentSetting: action.experimentSetting};
    case SAVE_GENE_EXPRESSION_TABLE_LIST :
      return {...state, geneExpressionTableList: action.geneExpressionTableList};
    case SAVE_BIOLOGICAL_GROUPS_LIST :
      return {...state, biologicalGroupsList: action.biologicalGroupsList};
    case SAVE_CHART_OPTION :
      return {...state, chartOption: action.chartOption};
    case SAVE_TARGET_CQ_DATA :
      return {...state, targetCqData: action.targetCqData};
    case SAVE_TABLE_DATA :
      return {...state, tableData: action.tableData};
    case SAVE_TECHNICAL_TABLE_DATA :
      return {...state, technicalTableData: action.technicalTableData};
    case SAVE_BIOLOGICAL_TABLE_DATA :
      return {...state, biologicalTableData: action.biologicalTableData};
    case SAVE_BIOLOGICAL_CQ_DATA :
      return {...state, biologicalCqData: action.biologicalCqData};
    default:
      return state;
  }
}

export default reducer;
